package com.example.controller.login;

import com.example.enums.Meiju;
import com.example.pojo.User;
import com.example.service.login.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * @Author: zdp
     * @Description: 查询密码
     * @DateTime: 13:28 2022/11/13
     * @Params: account接收账号，password密码，根据账号查询密码
     * @Return
     * @return
     */
    @ResponseBody
    @PostMapping("/password")
    @CrossOrigin
    public Integer get(HttpServletRequest request, @RequestParam("account") String account, @RequestParam("password") String password){
        User user = userService.get(account);
        if(user==null){
            return Meiju.ZHANGHAOCUOWU.getA();
        }
        if(!user.getPassword().equals(password)){
            return Meiju.MIMACUOWU.getA();
        }
        return Meiju.CHENGGONG.getA();
    }
}